home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 58 / pcpp58a.iso / extras / quake 3 source / Q3A_ToolSource.exe / Main / POINTS.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-02  |  3.1 KB  |  136 lines

  1. #include "stdafx.h"
  2.  
  3. #include "qe3.h"
  4.  
  5.  
  6. #define    MAX_POINTFILE    8192
  7. static vec3_t    s_pointvecs[MAX_POINTFILE];
  8. static int        s_num_points, s_check_point;
  9.  
  10. void Pointfile_Delete (void)
  11. {
  12.     char    name[1024];
  13.  
  14.     strcpy (name, currentmap);
  15.     StripExtension (name);
  16.     strcat (name, ".lin");
  17.  
  18.     remove(name);
  19. }
  20.  
  21. // advance camera to next point
  22. void Pointfile_Next (void)
  23. {
  24.     vec3_t    dir;
  25.  
  26.     if (s_check_point >= s_num_points-2)
  27.     {
  28.         Sys_Status ("End of pointfile", 0);
  29.         return;
  30.     }
  31.     s_check_point++;
  32.     VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetCamera()->Camera().origin);
  33.     VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetXYWnd()->GetOrigin());
  34.     VectorSubtract (s_pointvecs[s_check_point+1], g_pParentWnd->GetCamera()->Camera().origin, dir);
  35.     VectorNormalize (dir);
  36.     g_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
  37.     g_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;
  38.  
  39.     Sys_UpdateWindows (W_ALL);
  40. }
  41.  
  42. // advance camera to previous point
  43. void Pointfile_Prev (void)
  44. {
  45.     vec3_t    dir;
  46.  
  47.     if ( s_check_point == 0)
  48.     {
  49.         Sys_Status ("Start of pointfile", 0);
  50.         return;
  51.     }
  52.     s_check_point--;
  53.     VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetCamera()->Camera().origin);
  54.     VectorCopy (s_pointvecs[s_check_point], g_pParentWnd->GetXYWnd()->GetOrigin());
  55.     VectorSubtract (s_pointvecs[s_check_point+1], g_pParentWnd->GetCamera()->Camera().origin, dir);
  56.     VectorNormalize (dir);
  57.     g_pParentWnd->GetCamera()->Camera().angles[1] = atan2 (dir[1], dir[0])*180/3.14159;
  58.     g_pParentWnd->GetCamera()->Camera().angles[0] = asin (dir[2])*180/3.14159;
  59.  
  60.     Sys_UpdateWindows (W_ALL);
  61. }
  62.  
  63. void WINAPI Pointfile_Check (void)
  64. {
  65.     char    name[1024];
  66.     FILE    *f;
  67.     vec3_t    v;
  68.  
  69.     strcpy (name, currentmap);
  70.     StripExtension (name);
  71.     strcat (name, ".lin");
  72.  
  73.     f = fopen (name, "r");
  74.     if (!f)
  75.         return;
  76.  
  77.     Sys_Printf ("Reading pointfile %s\n", name);
  78.  
  79.     if (!g_qeglobals.d_pointfile_display_list)
  80.         g_qeglobals.d_pointfile_display_list = qglGenLists(1);
  81.  
  82.     s_num_points = 0;
  83.   qglNewList (g_qeglobals.d_pointfile_display_list,  GL_COMPILE);
  84.     qglColor3f (1, 0, 0);
  85.     qglDisable(GL_TEXTURE_2D);
  86.     qglDisable(GL_TEXTURE_1D);
  87.     qglLineWidth (4);
  88.     qglBegin(GL_LINE_STRIP);
  89.     do
  90.     {
  91.         if (fscanf (f, "%f %f %f\n", &v[0], &v[1], &v[2]) != 3)
  92.             break;
  93.         if (s_num_points < MAX_POINTFILE)
  94.         {
  95.             VectorCopy (v, s_pointvecs[s_num_points]);
  96.             s_num_points++;
  97.         }
  98.         qglVertex3fv (v);
  99.     } while (1);
  100.     qglEnd();
  101.     qglLineWidth (1);
  102.     qglEndList ();
  103.  
  104.     s_check_point = 0;
  105.     fclose (f);
  106.     //Pointfile_Next ();
  107. }
  108.  
  109. void Pointfile_Draw( void )
  110. {
  111.     int i;
  112.  
  113.     qglColor3f( 1.0F, 0.0F, 0.0F );
  114.     qglDisable(GL_TEXTURE_2D);
  115.     qglDisable(GL_TEXTURE_1D);
  116.     qglLineWidth (4);
  117.     qglBegin(GL_LINE_STRIP);
  118.     for ( i = 0; i < s_num_points; i++ )
  119.     {
  120.         qglVertex3fv( s_pointvecs[i] );
  121.     }
  122.     qglEnd();
  123.     qglLineWidth( 1 );
  124. }
  125.  
  126. void Pointfile_Clear (void)
  127. {
  128.     if (!g_qeglobals.d_pointfile_display_list)
  129.         return;
  130.  
  131.     qglDeleteLists (g_qeglobals.d_pointfile_display_list, 1);
  132.     g_qeglobals.d_pointfile_display_list = 0;
  133.     Sys_UpdateWindows (W_ALL);
  134. }
  135.  
  136.